class Solution:
    def countSubstrings(self, s: str) -> int:
        total=0
        for i in range(1,len(s)):
            if s[i-1]==s[i]:
                flag=True
                step=1
                total+=1
                while flag and i-1-step>=0 and i+step<=len(s)-1:
                    if s[i-1-step]==s[i+step]:
                        total+=1
                    else:
                        flag=False
                    step+=1
            try:
                if s[i-1]==s[i+1]:
                    flag=True
                    step=1
                    total+=1
                    while flag and i-1-step>=0 and i+1+step<=len(s)-1:
                        if s[i-1-step]==s[i+1+step]:
                            total+=1
                        else:
                            flag=False
                        step+=1
            except:
                pass

        return total+len(s)

solution=Solution()
print(solution.countSubstrings("aaaaa"))